package com.haoxin.ai_course.modules.course.mapper;

import java.math.BigDecimal;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.haoxin.ai_course.modules.course.entity.AcStatisticsCourse;

/**
 * 课程统计表
 * 
 * @author xingxiangguo
 * @email bugcn@qq.com
 * @date 2022-06-06 09:44:49
 */
public interface AcStatisticsCourseMapper  extends BaseMapper<AcStatisticsCourse> {
	@Select("select ifnull(sum(studay_time)/count(1),0) from ac_statistics_user where course_id=#{courseId} and course_finish = 1")
	Integer getFinishCourseAvageTime(int courseId);
@Update("update ac_statistics_course set version=#{acStatisticsCourse.version}+1,enter_course_count=#{acStatisticsCourse.enterCourseCount},single_course_finish_rate =#{acStatisticsCourse.singleCourseFinishRate}    where id = #{acStatisticsCourse.id} and version=  #{acStatisticsCourse.version}")
	void updateByVersion(@Param("acStatisticsCourse")  AcStatisticsCourse acStatisticsCourse);
	
}
